store 0 to namelen,namel
store space(30) to voidpw
namelen=len(alltrim(staf_name))
store .f. to exactpw,accpw
do nameleng
*do while .not. accpw .and. lastkey()<>27
do while .not. accpw
   store space(10) to pw1,pw2
   STORE 0 TO pwl1,pwl2,l11,l12,l13,l14,l15,l16,l17,l18,l19,l20,l21,l22,l23,l24,l25,l26,l27,l28,l29,l30,compt,cn,pwli
   SET COLOR TO W+/BG
   @ 12,4 clea to 22,75
   do boxt with 18,21,'Minimum 5, Maximum 10 letters long','gr+','r',.t.,.t.
   do while pwl1<5
      do boxe with 13,21,"Enter your Password :",'pw1','w+','b','X','n',10,.t.,.t.
      IF LASTKEY()=27
         RETURN
      ENDIF
      pwl1=len(alltrim(pw1))
      pwli=asc(str(pwl1,1,0))
   enddo
   l11=asc(left(pw1,1))
   l12=asc(substr(pw1,2,1))
   l13=asc(substr(pw1,3,1))
   l14=asc(substr(pw1,4,1))
   l15=asc(substr(pw1,5,1))
   if pwl1>5
      l16=asc(substr(pw1,6,1))
      if pwl1>6
         l17=asc(substr(pw1,7,1))
         if pwl1>7
            l18=asc(substr(pw1,8,1))
            if pwl1>8
               l19=asc(substr(pw1,9,1))
               if pwl1>7
                  l20=asc(substr(pw1,10,1))
               endif
            endif
         endif
      endif
   endif
   do while .not. exactpw
      compt=compt+1
      if compt=3
         return
      endif
      do boxe with 13,21,"Retype the Password :",'pw2','w+*','b','X','n',10,.t.,.t.
      pwl2=len(alltrim(pw2))
      if pwl1<>pwl2
         loop
      endif
      l21=asc(left(pw2,1))
      l22=asc(substr(pw2,2,1))
      l23=asc(substr(pw2,3,1))
      l24=asc(substr(pw2,4,1))
      l25=asc(substr(pw2,5,1))
      if pwl2>5
         l26=asc(substr(pw2,6,1))
         if pwl2>6
            l27=asc(substr(pw2,7,1))
            if pwl2>7
               l28=asc(substr(pw2,8,1))
               if pwl1>8
                  l29=asc(substr(pw1,9,1))
                  if pwl1>7
                     l30=asc(substr(pw1,10,1))
                  endif
               endif
            endif
         endif
      endif
      do case
         case pwl1=5
            if l11=l21 .and. l12=l22 .and. l13=l23 .and. l14=l24 .and. l15=l25
               exactpw=.t.
            endif
         case pwl1=6
            if l11=l21 .and. l12=l22 .and. l13=l23 .and. l14=l24 .and. l15=l25 .and.l16=l26
               exactpw=.t.
            endif
         case pwl1=7
            if l11=l21 .and. l12=l22 .and. l13=l23 .and. l14=l24 .and. l15=l25 .and.l16=l26 .and.l17=l27
               exactpw=.t.
            endif
         case pwl1=8
            if l11=l21 .and. l12=l22 .and. l13=l23 .and. l14=l24 .and. l15=l25 .and.l16=l26 .and.l17=l27 .and.l18=l28
               exactpw=.t.
            endif
         case pwl1=9
            if l11=l21 .and. l12=l22 .and. l13=l23 .and. l14=l24 .and. l15=l25 .and.l16=l26 .and.l17=l27 .and. l18=l28 .and. l19=l29
               exactpw=.t.
            endif
         case pwl1=10
            if l11=l21 .and. l12=l22 .and. l13=l23 .and. l14=l24 .and. l15=l25 .and.l16=l26 .and.l17=l27 .and.l18=l28  .and. l19=l29 .and. l20=l30
               exactpw=.t.
            endif
      endcase
   enddo
   store 0 to n01,n02,n03,n04,n05,n06,n07,n08,n09,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19,n20,n21,n22,n23,n24,n25,n26,n27,n28,n29,n30,n31,n32,n33,n34,n35,n36,n37,n38,n39,n40
   store space(1) to p01,p02,p03,p04,p05,p06,p07,p08,p09,p10,p11,p12,p13,p14,p15,p16,p17,p18,p19,p20,p21,p22,p23,p24,p25,p26,p27,p28,p29,p30,p31,p32,p33,p34,p35,p36,p37,p38,p39,p40
   do transfor
   do while cn<40
      cn=cn+1
      if cn<10
         cnn='0'+str(cn,1,0)
      else
         cnn=str(cn,2,0)
      endif
      prevar='n'+cnn
      divid=int(&prevar/142)
      multip=divid*142
      addit=&prevar-multip
      res=addit+32
      futvar='p'+cnn
      &futvar=chr(res)
   enddo
   result=p01+p02+p03+p04+p05+p06+p07+p08+p09+p10+p11+p12+p13+p14+p15+p16+p17+p18+p19+p20+p21+p22+p23+p24+p25+p26+p27+p28+p29+p30+p31+p32+p33+p34+p35+p36+p37+p38+p39+p40
   if result=staf_pw
      do boxf with 18,11,'You Cannot Use The SAME PASSWORD ... Type Any Key !','gr+','r+','gr+*',.t.,.t.
      exactpw=.f.
      set cons off
      wait ' '
      set cons on
   else
      accpw=.t.
   endif
enddo
if lastkey()=27
   return
endif
if accpw
   do codat
   if rec_lock(0)
      repl staf_pw with result,valid_pw with voidpw
   endif
   unlock
   set color to w/b
   Clea
   set color to w/bg
   @ 2,4 clea to 22,75
   do boxt with 10,16,'This PASSWORD will be valid for 3 months ...','gr+','b',.t.,.t.
   do boxt with 16,28,'Type any Key ... !!!','gr+','b',.t.,.t.
   SET CONS OFF
   wait ' '
   SET CONS ON
endif